package com.xktpx.controller;

import com.xktpx.common.utils.R;
import com.xktpx.common.validator.ValidatorUtils;
import com.xktpx.entity.SaleOrderEntity;
import com.xktpx.form.LoginForm;
import com.xktpx.result.BaseResult;
import com.xktpx.service.BuyOrderService;
import com.xktpx.service.SaleOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 杨浩
 * @create 2018-12-30 14:58
 **/
@RestController
@RequestMapping("/api/myBuy")
@Api(tags = "我的-购买")
public class ApiMyBuyController {


    @Autowired
    private SaleOrderService saleOrderService;

    @Autowired
    private BuyOrderService buyOrderService;

    @ApiOperation("购买-待付款")
    @GetMapping("/myPendingPayment")
    public BaseResult<List<SaleOrderEntity>> myPendingPayment(@ApiParam("当前页码") @RequestParam("pageNo") String pageNo,
                                                              @ApiParam("每页显示条数") @RequestParam("pageSize") String pageSize,
                                                              @ApiParam("用户id") @RequestParam("userId") Long userId) {


        return BaseResult.success(saleOrderService.queryMyShipment(pageNo, pageSize, userId,0));
    }

    @ApiOperation("购买-求购中")
    @GetMapping("/myBuyMedium")
    public BaseResult<List<SaleOrderEntity>> myBuyMedium(@ApiParam("当前页码") @RequestParam("pageNo") String pageNo,
                                                         @ApiParam("每页显示条数") @RequestParam("pageSize") String pageSize,
                                                         @ApiParam("用户id") @RequestParam("userId") Long userId) {


        return BaseResult.success(saleOrderService.queryMyShipment(pageNo, pageSize, userId,0));
    }

    @ApiOperation("购买-待发货")
    @GetMapping("/myToBeShipped")
    public BaseResult<List<SaleOrderEntity>> myToBeShipped(@ApiParam("当前页码") @RequestParam("pageNo") String pageNo,
                                                           @ApiParam("每页显示条数") @RequestParam("pageSize") String pageSize,
                                                           @ApiParam("用户id") @RequestParam("userId") Long userId) {


        return BaseResult.success(saleOrderService.queryMyShipment(pageNo, pageSize, userId,0));
    }

    @ApiOperation("购买-待收货")
    @GetMapping("/myGoodsToBeReceived")
    public BaseResult<List<SaleOrderEntity>> myGoodsToBeReceived(@ApiParam("当前页码") @RequestParam("pageNo") String pageNo,
                                                                 @ApiParam("每页显示条数") @RequestParam("pageSize") String pageSize,
                                                                 @ApiParam("用户id") @RequestParam("userId") Long userId) {


        return BaseResult.success(saleOrderService.queryMyShipment(pageNo, pageSize, userId,0));
    }

    @ApiOperation("购买-历史订单")
    @GetMapping("/myBuyHistorical")
    public BaseResult<List<SaleOrderEntity>> myBuyHistorical(@ApiParam("当前页码") @RequestParam("pageNo") String pageNo,
                                                             @ApiParam("每页显示条数") @RequestParam("pageSize") String pageSize,
                                                             @ApiParam("用户id") @RequestParam("userId") Long userId) {


        return BaseResult.success(saleOrderService.queryMyShipment(pageNo, pageSize, userId,0));
    }

    @ApiOperation("关闭订单")
    @GetMapping("/closeOrder")
    public R closeOrder(@ApiParam("订单ID") @RequestParam("orderId") Integer orderId) {
        //表单校验


        //用户登录
        return R.ok();
    }

    @ApiOperation("买家支付保证金")
    @GetMapping("/buyerDownpayment")
    public R buyerDownpayment(@ApiParam("订单ID") @RequestParam("orderId") Integer orderId,
                              @ApiParam("金额") @RequestParam("price") BigDecimal price) {
        //表单校验


        //用户登录
        return R.ok();
    }

    @ApiOperation("买家删除订单记录")
    @GetMapping("/buyerDeleteOrderInfo")
    public R buyerDeleteOrderInfo(@ApiParam("订单ID") @RequestParam("orderId") Integer orderId) {
        //表单校验


        //用户登录
        return R.ok();
    }
}
